﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownList1.Items.Add("男");
                DropDownList1.Items.Add("女");
                DropDownList2.Items.Add("福建");
                DropDownList2.Items.Add("江西");
                DropDownList3.Items.Add("龙岩");
                DropDownList3.Items.Add("福州");
            }
        }

        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string province = DropDownList2.SelectedValue;
            DropDownList3.Items.Clear();
            if (province=="福建")
            {
                DropDownList3.Items.Add("龙岩");
                DropDownList3.Items.Add("福州");
            }
            else
            {
                DropDownList3.Items.Add("萍乡");
                DropDownList3.Items.Add("南昌");
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string fileName = FileUpload1.FileName;
                if (fileName.EndsWith(".jpg")|| fileName.EndsWith(".png")||fileName.EndsWith(".jpeg"))
                {
                    string file = Server.MapPath("/img/"+fileName);
                    FileUpload1.SaveAs(file);
                    Image1.ImageUrl = "/img/" + fileName;
                    Image1.Visible = true;
                }
            }
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            Label9.Text = $"用户名为:{TextBox1.Text},用户的性别为:{DropDownList1.SelectedValue},用户的爱好为:{TextBox3.Text},用户的籍贯为{DropDownList2.SelectedValue}省{DropDownList3.SelectedValue}市;用户的其它信息为:{TextBox4.Text}.";
        }
    }
}